import { RouteRecordRaw } from "vue-router";
import ExampleView from "../views/ExampleView.vue";
import AdminView from "@/views/AdminView.vue";
import NoAuth from "@/views/NoAuth.vue";
import ACCESS_ENUM from "@/access/accessEnum";
import UserLayout from "@/layouts/UserLayout.vue";
import UserLoginView from "@/views/User/UserLoginView.vue";
import UserRegisterView from "@/views/User/UserRegisterView.vue";
import QuestionAdd from "@/views/Question/QuestionAdd.vue";
import QuestionMessageView from "@/views/Question/questionMessageView.vue";
import QuestionUpdateView from "@/views/Question/QuestionUpdateView.vue";
import QuestionView from "@/views/Question/QuestionView.vue";
import QuestionDetailView from "@/views/Question/questionDetailView.vue";
import QuestionSubmitView from "@/views/Question/QuestionSubmitView.vue";
import QuestionSubmitManageView from "@/views/Question/QuestionSubmitManageView.vue";
import UserCenterView from "@/views/User/UserCenterView.vue";
import UserMessageView from "@/views/User/UserMessageView.vue";
import PostListView from "@/views/Post/PostListView.vue";
import PostAddView from "@/views/Post/PostAddView.vue";
import PostUpdateView from "@/views/Post/PostUpdateView.vue";
import PostDetailView from "@/views/Post/PostDetailView.vue";

// eslint-disable-next-line prettier/prettier
export const routes: Array<RouteRecordRaw> = [
  {
    path: "/user",
    name: "用户",
    component: UserLayout,
    meta: {
      hideInMenu: true,
    },
    // 子路由机制 别忘了在父组件中写上routes-view
    children: [
      {
        path: "/user/login",
        name: "登录",
        component: UserLoginView,
      },
      {
        path: "/user/register",
        name: "注册",
        component: UserRegisterView,
      },
    ],
  },
  {
    path: "/",
    name: "题库",
    component: QuestionView,
  },
  {
    path: "/question/detail/:id",
    name: "题目详情页",
    component: QuestionDetailView,
    meta: {
      hideInMenu: true,
    },
  },
  {
    path: "/example",
    name: "测试页面",
    component: ExampleView,
    meta: {
      hideInMenu: true,
    },
  },
  {
    path: "/user/center/",
    name: "个人中心",
    component: UserCenterView,
    meta: {
      access: ACCESS_ENUM.USER,
    },
  },
  {
    path: "/user/view/",
    name: "用户信息页",
    component: UserMessageView,
    meta: {
      access: ACCESS_ENUM.ADMIN,
    },
  },
  {
    path: "/question/add",
    name: "创建题目",
    component: QuestionAdd,
    meta: {
      hideInMenu: false,
      access: ACCESS_ENUM.ADMIN,
    },
  },
  {
    path: "/question/message",
    name: "管理题目",
    component: QuestionMessageView,
    meta: {
      access: ACCESS_ENUM.ADMIN,
    },
  },
  {
    path: "/question/update/:id",
    name: "题目修改",
    component: QuestionUpdateView,
    meta: {
      hideInMenu: true,
    },
  },
  {
    path: "/questionSubmit/view/",
    name: "提交信息",
    component: QuestionSubmitView,
  },
  {
    path: "/questionSubmit/manage/",
    name: "提交信息管理",
    component: QuestionSubmitManageView,
    meta: {
      access: ACCESS_ENUM.ADMIN,
    },
  },
  {
    path: "/post/view/:id",
    name: "帖子詳情页面",
    component: PostDetailView,
    meta: {
      hideInMenu: true,
    },
  },
  {
    path: "/post/list/view/",
    name: "帖子页面",
    component: PostListView,
    meta: {
      access: ACCESS_ENUM.USER,
    },
  },
  {
    path: "/post/add/view/",
    name: "新增帖子",
    component: PostAddView,
    meta: {
      hideInMenu: true,
    },
  },
  {
    path: "/post/update/view/:postId",
    name: "修改帖子",
    component: PostUpdateView,
    meta: {
      hideInMenu: true,
    },
  },
  {
    path: "/noAuth",
    name: "无权限",
    component: NoAuth,
    meta: {
      hideInMenu: true,
    },
  },
];
